#!/bin/sh /etc/rc.common
START=50

run_njit()
{
	local enable
	config_get_bool enable $1 enable
	
	if [ $enable ]; then
		local username
		local password
		local domain
		local ifname
		
		config_get username $1 username
		config_get password $1 password
		config_get domain $1 domain
		config_get ifname $1 ifname
		
		if [ "$domain" != "" ]; then
			njit-client $username@$domain $password $ifname &
		else
			njit-client $username $password $ifname &
		fi
		
		echo "NJIT Client has started."
	fi
}

start()
{
	config_load njitclient
	config_foreach run_njit login
}

stop()
{
	killall njit-client
	killall udhcpc
	
	echo "NJIT Client has stoped."
}
